// ChuyenHenHoVersion1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "conio.h"
#include "stdio.h"
//int schoolboy;
//int schoolgirl;
//int homeboy;
//int homegirl;
//int pointdie;
//#define MAX 100
//#define VOCUC -1
//#define PATH "D:\\HENHO.IN"
//struct GRAPH
//{
//	int n;
//	int L[MAX][MAX];
//	
//};
//int schoolboy;
//int schoolgirl;
//int homeboy;
//int homegirl;
//int pointdie;
//int Weight[MAX];
//int Label[MAX];
//int T[MAX]; 
//int nT;
//void ReadFile(GRAPH &g)
//{
//	FILE *f=fopen(PATH,"rt");
//	if(!f)
//	{
//		printf("file is not exist");
//		return;
//	}
//	fscanf(f,"%d",&g.n);
//	
//	for(int i=0;i<g.n;i++)
//	{
//		for(int j=0;j<g.n;j++)
//			fscanf(f,"%d",&g.L[i][j]);
//		fscanf(f,"\n");
//	}
//	fscanf(f,"%d",&schoolboy);
//	schoolboy --;
//
//	fscanf(f,"%d",&schoolgirl);
//	schoolgirl --;
//
//	fscanf(f,"%d",&homeboy);
//	homeboy --;
//
//	fscanf(f,"%d",&homegirl);
//	homegirl --;
//
//	fscanf(f,"%d",&pointdie);
//	pointdie --;
//}
//void InIt(GRAPH g,int point)
//{
//	nT = g.n; 
//	for (int i=0;i<nT;i++)
//	{
//		T[i]=1;
//		Weight[i]=VOCUC;
//		Label[i]=-1;
//	}
//	Weight[point]=0;//point is start point
//}
//void DijkStraAlg(GRAPH g,int startpoint,int endpoint)
//{
//	InIt(g,startpoint);
//	int v;
//	int min;
//	while(T[endpoint]==1)
//	{
//		min=VOCUC;
//		v=-1;
//		for (int i=0;i<g.n;i++)
//		{
//			if ((T[i]==1)&&(Weight[i]!=VOCUC))
//				if (min==VOCUC || min>Weight[i])
//				{
//					min=Weight[i];
//					v=i;
//				}
//		}
//		T[v]=0;
//		for (int j=0;j<g.n;j++)
//		{
//			if ((g.L[v][j]!=0)&&(T[j]==1))
//				if((Weight[j]==VOCUC) || (Weight[j]>Weight[v]+g.L[v][j]))
//				{
//					Weight[j]=Weight[v]+g.L[v][j];
//					Label[j]=v;
//				}
//		}
//}
//}
void main()
{
	GRAPH g;
	ReadFile(g);
	
	printf("so dinh : %d",g.n);
	printf("\ntruong trai : %d",g.schoolboy+1);
	printf("\ntruong gai : %d",g.schoolgirl+1);
	printf("\nnha trai : %d",g.homeboy+1);
	printf("\nnha gai : %d",g.homegirl+1);
	printf("\ndem hen : %d",g.pointdie+1);

	DijkStraAlg(g,g.schoolboy,g.pointdie);
	int SchoolBPointWeight=g.Weight[g.pointdie];

	DijkStraAlg(g,g.schoolgirl,g.pointdie);
	int SchoolGPointWeight=g.Weight[g.pointdie];

	DijkStraAlg(g,g.pointdie,g.homeboy);
	int  PointHomeBWeight=g.Weight[g.homeboy];

	DijkStraAlg(g,g.pointdie,g.homegirl);
	int  PointHomeGWeight=g.Weight[g.homegirl];

	int  total=SchoolBPointWeight+SchoolGPointWeight+PointHomeBWeight+PointHomeGWeight;
	printf("\n\ntotal weight for this trip : %d",total);
	FILE *f=fopen("D:\\HENHO.OUT","wt");
	
	if(!f)
	{
		printf("file is not exist");
		return;
	}
	fprintf(f,"%d",total);
	fclose(f);

}


//int _tmain(int argc, _TCHAR* argv[])
//{
//	return 0;
//}

